package com.example.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisUtils {

    private static JedisPool jp;

    static {
        //创建一个Jedis连接池
        JedisPoolConfig config = new JedisPoolConfig();
        //最小容量（初始容量）
        config.setMaxIdle(5);
        //最大容量
        config.setMaxTotal(50);
        //等待超时(单位ms)
        config.setMaxWaitMillis(5000);

        String host = "192.168.247.132";
        int port = 6379;

        jp = new JedisPool(config,host,port);
    }

    public static Jedis getJedis(){
        return jp.getResource();
    }
}
